﻿using EFFC.Frame.Net.Module.Extend.EWRA.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EFFC.Extends.LinqDLR2SQL;
using EFFC.Frame.Net.Unit.DB;
using EFFC.Frame.Net.Base.Data.Base;
using ICPFrameLib.Business;
using ICPFrameLib.Attributes;
using EFFC.Frame.Net.Base.Common;

namespace XHRPMIS.Business.v1._0
{
    public class Menu : MyRestLogic
{
    [EWRARouteDesc("获取当前登录者的菜单的列表")]
    [EWRAOutputDesc("返回结果", @"{
result:[数据集]
}")]
    public override List<object> get()
    {
        SetCacheEnable(false);
        var up = DB.NewMetaUnitParameter();
        var s = from t2 in DB.LamdaTable(up, "EXTEND_ROLE_FUNCTION", "b")
                join t3 in DB.LamdaTable(up, "EXTEND_FUNCTION", "c") on t2.functionno equals t3.functionno
                where t2.RoleNo.within(ComFunc.nvl(TokenPayLoad["roleno"])) && t3.is_menu == 1
                orderby t3.sortnum
                select new
                {
                    function_no = t3.functionno,
                    function_name = t3.functionname,
                    function_url = t3.functionurl,
                    p_function_no = t3.p_functionno,
                    sort_num = t3.sortnum,
                    target = t3.target,
                    url_type = t3.urltype,
                    icon = t3.Icon
                };
        return s.Distinct().Query(up).QueryData<object>();
    }
}
}
